package com.go.where.manager.action.go;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import com.go.where.manager.action.SuperAction;
import com.go.where.manager.common.Constants;
import com.go.where.manager.page.Pagination;
import com.go.where.manager.pojo.CustomerReportInfo;
import com.go.where.manager.service.CustomerReportService;
import com.go.where.manager.util.CommonUtil;
import com.google.gson.Gson;

public class CustomerReportAction extends SuperAction {

	private static final long serialVersionUID = 1L;
	private static final Logger log = Logger
			.getLogger(CustomerReportAction.class);
	@Resource(name = "customerReportService")
	private CustomerReportService customerAddressService;
	private CustomerReportInfo customerReportInfo;
	private CustomerReportInfo customerReportInfoQuery;
	private String id;
	public Pagination<?> page;

	Gson gson = CommonUtil.gson();

	/**
	 * 查询列表
	 * 
	 * @return
	 */
	public String list() {
		if (customerReportInfoQuery == null) {
			customerReportInfoQuery = new CustomerReportInfo();
			customerReportInfoQuery.setPageSize(Constants.INIT_PAGESIZE);
			customerReportInfoQuery.setCurrentPage(Constants.INIT_CURRENTPAGE);
		}
		try {
			customerReportInfoQuery.setIsDelete(Constants.NOT_DELETED);
			page = customerAddressService.queryPage(customerReportInfoQuery);
		} catch (Exception e) {
			addActionError(e.getMessage());
			log.error("查询信息异常", e);
		}

		return LIST;
	}

	/**
	 * 假删除
	 * 
	 * @return
	 */
	public String falseDelete() {
		customerReportInfo = new CustomerReportInfo();
		customerReportInfo.setId(id);
		customerReportInfo.setIsDelete(Constants.DELETED);
		try {
			this.redirectionUrl = "customer_report!list.htm";
			customerAddressService.update(customerReportInfo);
		} catch (Exception e) {
			addActionError("删除信息异常" + e.getMessage());
			log.error("删除信息异常", e);
		}
		return SUCCESS;
	}

	public CustomerReportInfo getCustomerReportInfo() {
		return customerReportInfo;
	}

	public void setCustomerReportInfo(CustomerReportInfo customerReportInfo) {
		this.customerReportInfo = customerReportInfo;
	}

	public CustomerReportInfo getCustomerReportInfoQuery() {
		return customerReportInfoQuery;
	}

	public void setCustomerReportInfoQuery(
			CustomerReportInfo customerReportInfoQuery) {
		this.customerReportInfoQuery = customerReportInfoQuery;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Pagination<?> getPage() {
		return page;
	}

	public void setPage(Pagination<?> page) {
		this.page = page;
	}

}
